from django.db import models
from django.utils import timezone

from Stage.models import Stage
from module.models import Module


# Create your models here.

class Task(models.Model):
    title = models.TextField(db_comment="任务标题")
    level = models.IntegerField(db_comment="难易程度",
                             null=True,
                             blank=True,
                             choices=((1, '简单'), (2, '中等'), (3, '困难'),(4,'选做')))
    stage = models.ForeignKey(to=Stage,
                              blank=True,
                              null=True,
                              on_delete=models.CASCADE)
    module = models.ForeignKey(to=Module,
                               blank=True,
                               null=True,
                               on_delete=models.CASCADE)
    create_time = models.DateTimeField(db_comment='创建时间', default=timezone.now, blank=True, null=True)
    update_time = models.DateTimeField(db_comment='修改时间', blank=True, null=True)
    delete_time = models.DateTimeField(db_comment='删除时间', blank=True, null=True)
    is_delete = models.BooleanField(db_comment='是否删除', default=False)

    class Meta:
        db_table = 'tb_task'
